#include "Camera.h"

Camera::Camera()
{
	q = Quad();
	q.x = q.y = q.h = q.w = 0;
	follow = 0;
	mobile = true;
}

Camera::Camera(int w, int h)
{
	q = Quad();
	q.x = q.y = 0;
	q.w = w;
	q.h = h;
	follow = 0;
	mobile = true;
}

void Camera::fix()
{
	mobile = false;
}

void Camera::fix(float x, float y)
{
	mobile = false;
	q.x = x;
	q.y = y;
}

void Camera::follow(FrameComp* fc)
{
	follow = fc;
	mobile = true;
}

void Camera::update()
{
	Quad f = follow.getQuad();

	q.x = (f.x + (f.w/2)) - q.w;
	q.y = (f.y + (f.h/2)) - q.h;
}

Quad Camera::getQuad()
{
	return q;
}
